<?
//引入所有子系统信息
include_once("../../../common/script/extender_import.php");


//**获取当前板块资料，必然载入，后续很多读取板块数据库的表格，都写成动态的了。
$_plate=$plate['asset'];


//根据页面数量信息，筛选信息，创造url，供页码,跳转等使用
include_once("script/set_url.php");




//[select_text_product] => brandtest,12345

//print_r2($_REQUEST);

$_REQUEST['ai_product']=$_REQUEST['select_text_product'];

$_product_id_list=explode(",",$_REQUEST['select_text_product']);

//print_r2($_product_id_list);

foreach ($_product_id_list as $product_id)
{
    //查找该产品所有所属的relation分类
    $_category_list=select_lines_all_items($table_prefix."relation","","detail_nid = '{$product_id}' ","");
    //print_r2($_category_list);

    $_REQUEST['ai_product_category']=$_REQUEST['ai_product_category'].implode(",",transform_2darray_in_1darray_number_as_key($_category_list,'term_nid'));
}



    //这里是设计上传文件的部分：包含图片和附件。视频也应该用这种形式上传
    //统一设置一下保存图片的路径
    $_uf['path']        = ROOT_PATH_ . "/uploadfiles/".$theme_folder."/";

    //创建删除文件存放文件夹
    if(!file_exists($_uf['path'] ."/delete/")){
        mkdir($_uf['path'] ."/delete/",0777,true);
        chmod($_uf['path'] ."/delete/",0777);
    }




    //上传icon
    if (is_uploaded_file($_FILES['icon']['tmp_name']))
    {
        $_uf['upfile']       = $_FILES['icon'];
        $_info               = upload_file($_uf);
        $_REQUEST['ai_icon'] = $_info['name'];
        if(($_REQUEST['ai_icon'])&&($old_detail['icon']!="alpha.gif"))
        {
            rename($_uf['path'].$old_detail['icon'], $_uf['path'] ."delete/".$old_detail['icon']);
        }
    }
 

    //上传附件
    if (is_uploaded_file($_FILES['filename']['tmp_name'])) {
        $_uf["allowExt"] = array('jpeg',
            'jpg',
            'png',
            'gif',
            'rar',
            'zip',
            '7zip',
            'exe',
            'msi',
            'txt',
            'doc',
            'xlsx',
            'pptx',
            'pdf',
            'webp');
        $_uf['upfile']             = $_FILES['filename'];
        $_info                     = upload_file($_uf);
        $_REQUEST['ai_filename'] = $_info['name'];
        if($_REQUEST['ai_filename']){
            rename($_uf['path'].$old_detail['filename'], $_uf['path'] ."delete/".$old_detail['filename']);
        }
    }



//处理数据并且update
//获取数据

$sql=update_date($table_prefix.$_plate['table']['data'],$_REQUEST,"nid",$_REQUEST['nid']);
$query = mysql_query($sql) or die ("error:".mysql_error());

?>

